package com.yuxi;

/**
 * Created by yuxi on 17/2/3.
 */
public class DoubleChecked {
    private static DoubleChecked doubleChecked;

    private DoubleChecked() {
    }

    public static DoubleChecked getInstance() {
        if (doubleChecked == null) {//第一次检查
            synchronized (DoubleChecked.class) {//加锁
                if (doubleChecked == null) {//再次检查
                    doubleChecked = new DoubleChecked();//创建对象,问题的根源
                }
            }
        }
        return doubleChecked;
    }
}
